package com.ruibang.glass.produce.controller.hotRealTime;

import com.ruibang.glass.frequencycontrol.annotation.FrequencyControl;
import com.ruibang.glass.produce.domain.req.FlowRateTrendReq;
import com.ruibang.glass.produce.domain.req.ThicknessTrendReq;
import com.ruibang.glass.produce.domain.req.TrafficTrendReq;
import com.ruibang.glass.produce.service.HotRealTimeService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @Author: songJinKang
 * @CreateTime: 2023-11-23  15:53
 * @Description: TODO
 * @Version: 1.0
 */

@Api(tags = "热端实时控制器")
@RestController
@RequestMapping("/api/glass/produce/hotRealTime")
public class HotRealTimeController {

    @Autowired
    private HotRealTimeService hotRealTimeService;

    @PostMapping("/thicknessTrend")
    @ApiOperation(value = "测厚趋势图", response = ResultBody.class)
    public ResultBody thicknessTrend(@RequestBody @Valid ThicknessTrendReq thicknessTrendReq) {
        return ResultBody.success(hotRealTimeService.thicknessTrend(thicknessTrendReq));
    }

    @PostMapping("/flowRateTrend")
    @ApiOperation(value = "玻璃流速趋势图", response = ResultBody.class)
    public ResultBody flowRateTrend(@RequestBody FlowRateTrendReq flowRateTrendReq) {
        return ResultBody.success(hotRealTimeService.flowRateTrend(flowRateTrendReq));
    }

    @PostMapping("/weighingTrend")
    @ApiOperation(value = "称重趋势图", response = ResultBody.class)
    public ResultBody weighingTrend(@RequestBody FlowRateTrendReq flowRateTrendReq) {
        return ResultBody.success(hotRealTimeService.weighingTrend(flowRateTrendReq));
    }

    @PostMapping("/trafficTrend")
    @ApiOperation(value = "流量趋势", response = ResultBody.class)
    public ResultBody trafficTrend(@RequestBody TrafficTrendReq trafficTrendReq) {
        return ResultBody.success(hotRealTimeService.trafficTrend(trafficTrendReq));
    }

    @PostMapping("/exportForceCutLength")
    @ApiOperation(value = "刀压切割长度数据导出", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    public void exportForceCutLength(@RequestBody FlowRateTrendReq flowRateTrendReq, HttpServletResponse response) {
        hotRealTimeService.exportForceCutLength(flowRateTrendReq, response);
    }

    @PostMapping("/queryForceCutLengthData")
    @ApiOperation(value = "查询刀压切割长度数据", response = ResultBody.class)
    public ResultBody queryForceCutLengthData(@RequestBody FlowRateTrendReq flowRateTrendReq) {
        return ResultBody.success(hotRealTimeService.queryForceCutLengthData(flowRateTrendReq));
    }
}
